using DC2010.Objects.Base;
using DC2010.Objects;
using DC2010.Objects.Data;

namespace DC2010.Effects
{

/// Effect description
/// 
/// Param1 - Points added to attribute
/// Param2 -  Party(>1) or Solo(1) effect
/// Param3 - UNUSED
/// Param4 - UNUSED
/// Param5 -  UNUSED
/// sParam1 - HEALTH
///           STAMINA
///           MANA
///           LUCK
///           STR
///           DEX
///           WIS
///           VIT
///           ANF - AntiFire
///           ANA - AntiAir
///           ANE - AntiEarth
///           ANW - AntiWater
/// sParam2 - Direction, shield can be negative as well as positive, values are: "+", "-".

 
    public class P_ManipulateAttribute_Effect : EffectLogic
    {
        public P_ManipulateAttribute_Effect(EffectData ed)
            : base(ed)
        {
            ShortName = "INCREASE STAT";
            LongName = "Effect increases/decreses specific stat for creature.";
            Id = "I_INCREASE_STAT_EFFECT";
            EffectType = EffectType.Instant;
        }


        public int counter;

        public override bool CheckPumpCondition(BaseObject aTarget)
        {
            counter++;
            return (counter % 4)==0;
        }

        public override void Pump(BaseObject aTarget)
        {
            int amount = Data.Params.Find(A => A.Key == "AMOUNT").Value.ToInt();
            //string direction = Data.Params.Find(A => A.Key == "DIRECTION").Value;
            int party = Data.Params.Find(A => A.Key == "PARTY").Value.ToInt();


            if (CheckPumpCondition(aTarget))
            {
                if (aTarget is CreatureData)
                {
                    if (Info.ChargesCurrent != 0)
                    {

                        bool bEfectWholeParty = party == 1;
                       
                       if (!bEfectWholeParty)
                       {
                           HandleAttributes((CreatureData)aTarget, amount);
                       }
                       else
                       {
                           foreach(CreatureData c in Root.I.GameSystem.Party.MembersData)
                           {
                               HandleAttributes(c, amount);
                           }
                       }
                     
                       Info.ChargesCurrent--;
                    }
                }
            }
        }

        private void HandleAttributes(CreatureData c, int amount)
        {
            string stat = Data.Params.Find(A => A.Key == "STAT").Value;

            //if (stat == "HEALTH") c.Health.BoostedAmount = amount;
            //if (stat == "STAMINA") c.Stamina.BoostedAmount = amount;
            //if (stat == "MANA") c.Mana.BoostedAmount = amount;
            //if (stat == "LUCK") c.Luck.BoostedAmount = amount;
            //if (stat == "STR") c.Strength.BoostedAmount = amount;
            //if (stat == "DEX") c.Dexterity.BoostedAmount = amount;
            //if (stat == "WIS") c.Wisdom.BoostedAmount = amount;
            //if (stat == "VIT") c.Vitality.BoostedAmount = amount;
        }
    }
}
